<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text">
    +
    <input type="text">
    =
    <input type="text">
    <button onclick="plus()">加</button>
    <script>
        function plus() {
            var eleArr = document.getElementsByTagName("input");
            console.log(eleArr[0].value);
            var a = parseFloat(eleArr[0].value);
            var b = parseFloat(eleArr[1].value);
            // var c = eleArr[3].value;
            if (a && b && !isNaN(a + b)) {
                eleArr[2].value = a + b
            } else {
                alert("输入值有误");
            }
        }
    </script>
</body>

</html>